package com.farm.quartz.controller;

import com.farm.common.core.domain.AjaxResult;
import com.farm.quartz.Dao.haohaoAnimalsDao;
import com.farm.quartz.domain.YcyAnimalData;
import com.farm.quartz.model.haohaoAnimals;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import javax.annotation.Resource;
import java.util.ArrayList;
import java.util.List;

@RestController
@RequestMapping("/animalShow")
public class AnimalController {
    
    @Resource
    haohaoAnimalsDao dao;
    
    @GetMapping("animalNum")
    public AjaxResult animalNum() {
        ArrayList<YcyAnimalData> list = new ArrayList<>();
        for (haohaoAnimals haohaoAnimals : dao.findAll()) {
            list.add(new YcyAnimalData(haohaoAnimals.getName(), haohaoAnimals.getNumber()));
        }
    
    
        return AjaxResult.success("成功！", list);
    }
    
}
